Skip to content

Login: Several small UX fixes for Google login - #8022

Merged
nheagy merged 7 commits into
developfrom
feature/7675-google-ux-fixes
Oct 23, 2017
Merged

Login: Several small UX fixes for Google login#8022
nheagy merged 7 commits into
developfrom
feature/7675-google-ux-fixes

Conversation

@nheagy

@nheagy nheagy commented Oct 20, 2017

Copy link
Copy Markdown
Contributor

Refs #7675

  • Fixes next button spinning behaviour on email screen when using Google
  • Improves error shown when Google login succeeds but then fails on wpcom

To test:

Needs review: @aerych

@nheagy nheagy added the Login label Oct 20, 2017
@nheagy nheagy added this to the 8.7 milestone Oct 20, 2017
@nheagy nheagy self-assigned this Oct 20, 2017
@nheagy
nheagy requested a review from aerych October 20, 2017 20:12
let errorDescription: String
if (error as! NSError).code == WordPressComOAuthError.unknownUser.rawValue {
errorTitle = NSLocalizedString("Connected But…", comment:"Title shown when a user logs in with Google but no matching WordPress.com account is found")
errorDescription = NSLocalizedString("The Google account \"\(loginFields.username)\" doesn't match any account on WordPress.com", comment:"D shown when a user logs in with Google but no matching WordPress.com account is found")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Colon Violation: Colons should be next to the identifier when specifying a type and next to the key in dictionary literals. (colon)

let errorTitle: String
let errorDescription: String
if (error as! NSError).code == WordPressComOAuthError.unknownUser.rawValue {
errorTitle = NSLocalizedString("Connected But…", comment:"Title shown when a user logs in with Google but no matching WordPress.com account is found")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Colon Violation: Colons should be next to the identifier when specifying a type and next to the key in dictionary literals. (colon)

@nheagy nheagy mentioned this pull request Oct 20, 2017
17 tasks

@aerych aerych left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hiya @nheagy !
Just had a nitpick or two.
The only thing that would be a blocker is the comment about the responseObject vs responseDict. There's no compile error with this change because responseObject is an instance method... which means a function rather than a dictionary is being passed to errorFor(errorCode:errorDescription:responseObject:newNonce:)


error?.pointee = errorFor(errorCode: errorCode, errorDescription: errorDescription, responseObject: responseObject, newNonce: newNonce)
}
if [400, 409, 403].contains(httpResponse.statusCode),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So nice :)

var newNonce: String? = nil

// there's either a data object, or an error.
if let errorStr = responseDict["error"] as? String {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Diggin the refactor.

private func parseError(from responseDict: [String: AnyObject]) -> NSError {
var errorCode: String = ""
var errorDescription: String = ""
var newNonce: String? = nil

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpicky, but we could drop the type declarations for string :String since the assignment will take care of that via inference.
In the case of the optional, it would be assigned nil by default.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice find!

let errorDescription: String
if (error as NSError).code == WordPressComOAuthError.unknownUser.rawValue {
errorTitle = NSLocalizedString("Connected But…", comment: "Title shown when a user logs in with Google but no matching WordPress.com account is found")
errorDescription = NSLocalizedString("The Google account \"\(loginFields.username)\" doesn't match any account on WordPress.com", comment: "D shown when a user logs in with Google but no matching WordPress.com account is found")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment: "D shown ...
What's the D for?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol, I don't know why I didn't type escription after that 😂

newNonce = data["two_step_nonce"] as? String
}

return errorFor(errorCode: errorCode, errorDescription: errorDescription, responseObject: responseObject, newNonce: newNonce)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the changes here I think we need to pass responseDict instead of responseObject.

@nheagy

nheagy commented Oct 22, 2017

Copy link
Copy Markdown
Contributor Author

Thanks for finding those, @aerych. Should be ready for another look 😀

@aerych

aerych commented Oct 22, 2017

Copy link
Copy Markdown
Contributor

Looks good :) Buddybuild failed due to a compile error with something that looked Aztec related. I restarted. Assuming all checks are green we're good to :shipit: :)

@aerych

aerych commented Oct 22, 2017

Copy link
Copy Markdown
Contributor

Something seems off with buddybuild. All tests pass locally when I try. I think we're fine to just merge.

@nheagy
nheagy merged commit b13e92a into develop Oct 23, 2017
@nheagy

nheagy commented Oct 23, 2017

Copy link
Copy Markdown
Contributor Author

Thanks @aerych 👍

@nheagy
nheagy deleted the feature/7675-google-ux-fixes branch October 23, 2017 00:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants